<html>
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <head>
    <meta charset="UTF-8" />
    <title>js</title>
  </head>
  <body></body>

  <script>
    // var arr = [
    //   [1,2,3],
    //   [4,5,6],
    //   [7,8,9],
    // ]
    // let res = []
    // arr.forEach(vm => res.push([]))
    // arr.forEach((item, index) => {
    //   item.forEach((it, idx) => {
    //     if(idx % 3 === 0) res[idx].push(it)
    //     if(idx % 3 === 1) res[idx].push(it)
    //     if(idx % 3 === 2) res[idx].push(it)
    //   })
    // });
    // console.log(res);
    let arr = ["a", "c", "a", "c", "d", "b", "e"]

    Array.prototype.allCount = function () {
      let res = {}
      this.forEach(item => {
        if (res[item]) res[item]++
        else res[item] = 1
      })
      return res
    }
    
    
    console.log(arr)
    console.log('allCount', arr.allCount());
  </script>
</html>
